
// pom 配置文件 
// 自定义MapStruct映射关系


import com.tongtech.auth.utils.JacksonUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

// 此处注入  CustomizeConverter
@Mapper(componentModel = "spring", uses = {CustomizeConverter.class})
public interface ComplaintMapper {

    ComplaintMapper INSTANCE = Mappers.getMapper(ComplaintMapper.class);

    ComplaintAcceptSheetInVO toOutVO(ComplaintPersonalMain mainEntity);

    @Mappings({
            @Mapping(source = "params.srvReqstInfo.srvReqstFullName", target = "title"),

            @Mapping(target = "labelInfoList", expression = "java(InnerMapStruct.listToStr(inVO.getParams().getRiskInfo().getLabelInfoList()))"),
            @Mapping(target = "fileInfo", expression = "java(InnerMapStruct.listToStr(inVO.getParams().getFileInfo()))"),


// mapstruct 自定义调用另一个类的方法
            @Mapping(target = "channelSysCode", expression = "java(customizeConverter.queryDictName(inVO.getParams().getAcptInfo().getChannelSysCode(), \"channelSysCode\"))"),



    })
    ComplaintPersonalMain toEntity(ComplaintAcceptSheetInVO inVO);

    class InnerMapStruct {
        public static <T> String listToStr(List<T> listInput) {
            return JacksonUtils.objectToString(listInput);
        }
    }

}
